package com.service;

import com.dto.DeptDto;
import com.dto.UserDto;
import com.mapper.UserMapper;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public class UserMapperService {

    private final DeptMapperService deptMapperService;

    private final UserMapper userMapper;

    public UserMapperService(DeptMapperService deptMapperService, UserMapper userMapper) {
        this.deptMapperService = deptMapperService;
        this.userMapper = userMapper;
    }

    @Transactional
    public void addUserWithDept(UserDto user, DeptDto deptDto) {
        userMapper.addUser(user);
        deptMapperService.addDept(deptDto);
    }

    public List<UserDto> list() {
        return userMapper.page();
    }
}
